package net.bwie.jtp.jtprealtimeservice.controller;


import com.alibaba.fastjson.JSON;
import net.bwie.jtp.jtprealtimeservice.bean.TrafficSessionReport;
import net.bwie.jtp.jtprealtimeservice.bean.TrafficUvReport;
import net.bwie.jtp.jtprealtimeservice.service.TrafficChannelStatsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("jtp/traffic")
public class TrafficController {

    private static final String Date_default_value = "2025-05-18";

    @Autowired
    private  TrafficChannelStatsService trafficChannelStatsService;

   @RequestMapping("/UvCount")
    public String getUvCount(@RequestParam(value = "date",defaultValue = Date_default_value) String date){

       List<TrafficUvReport> uvCount = trafficChannelStatsService.getUvCount(date);


       return JSON.toJSONString(uvCount);
   }

    @RequestMapping("/SessionCount")
    public String getSessionCount(@RequestParam(value = "date",defaultValue = Date_default_value) String date){

        List<TrafficSessionReport> sessionCount = trafficChannelStatsService.getSessionCount(date);


        return JSON.toJSONString(sessionCount);
    }


}
